package com.demo.service.impl;


import java.util.List;

import com.demo.entity.po.AssessmentInfo;

import com.demo.entity.query.AssessmentInfoQuery;

import com.demo.entity.vo.PaginationResultVO;

import com.demo.service.AssessmentInfoService;

import org.springframework.stereotype.Service;

import javax.annotation.Resource;

import com.demo.entity.query.SimplePage;

import com.demo.mappers.AssessmentInfoMapper;

import com.demo.entity.enums.PageSize;

/**
 * @Description:心理自评结果表serviceImpl
 * @Date:2025-03-01
 * @author：author
*/
@Service("assessmentInfoService")
public class AssessmentInfoServiceImpl implements AssessmentInfoService{

	@Resource
	private AssessmentInfoMapper<AssessmentInfo,AssessmentInfoQuery> assessmentInfoMapper;

	/**
	 * 根据条件查询列表
	 */
	public List<AssessmentInfo> findListByParam(AssessmentInfoQuery query) { 
		return this.assessmentInfoMapper.selectList(query);
	}

	/**
	 * 根据条件查询数量
	 */
	public Integer findCountByParam(AssessmentInfoQuery query){
		return this.assessmentInfoMapper.selectCount(query);
	}

	/**
	 * 分页查询
	 */
	public PaginationResultVO<AssessmentInfo> findListByPage(AssessmentInfoQuery  query) { 
		int count = this.findCountByParam(query);
		int pageSize = query.getPageSize()==null?PageSize.SIZE15.getSize():query.getPageSize();
		SimplePage page = new SimplePage(query.getPageNo(),count,pageSize);
		query.setSimplePage(page);
		List<AssessmentInfo> list = this.findListByParam(query);
		return new PaginationResultVO(count,page.getPageSize(),page.getPageNo(),page.getPageTotal(),list);
	}

	/**
	 * 新增
	 */
	public Integer add(AssessmentInfo bean) { 
		return this.assessmentInfoMapper.insert(bean);
	}

	/**
	 * 批量新增
	 */
	public Integer addBatch(List<AssessmentInfo> listBean) { 
		if (listBean == null || listBean.isEmpty()) {
			return 0;
		}
		return this.assessmentInfoMapper.insertBatch(listBean);
	}

	/**
	 * 批量新增或者修改
	 */
	public Integer addOrUpdateBatch(List<AssessmentInfo> listBean) { 
		if (listBean == null || listBean.isEmpty()) {
			return 0;
		}
		return this.assessmentInfoMapper.insertOrUpdateBatch(listBean);
	}

	/**
	 * 根据AssessmentId查询
	 */
	public AssessmentInfo getAssessmentInfoByAssessmentId(Long assessmentId) { 
		return this.assessmentInfoMapper.selectByAssessmentId(assessmentId);
	}

	/**
	 * 根据AssessmentId更新
	 */
	public Integer updateAssessmentInfoByAssessmentId(AssessmentInfo bean, Long assessmentId) { 
		return this.assessmentInfoMapper.updateByAssessmentId(bean,assessmentId);
	}

	/**
	 * 根据AssessmentId删除
	 */
	public Integer deleteAssessmentInfoByAssessmentId(Long assessmentId) { 
		return this.assessmentInfoMapper.deleteByAssessmentId(assessmentId);
	}
}